package com.xander.qqdatabase.controller;

import com.xander.qqdatabase.base.ResultBean;
import com.xander.qqdatabase.entity.Log;
import com.xander.qqdatabase.entity.User;
import com.xander.qqdatabase.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author 叶振东
 * @date 2019-01-24
 */
@RestController
@RequestMapping("log")
public class LogController {
    @Autowired
    private LogService logService;

    @GetMapping("ajaxList")
    public ResultBean ajaxList(HttpSession session) {
        Log log = new Log();
        User user = (User) session.getAttribute("user");
        if (user.getIsAdmin() != 1) {
            log.setUid(user.getUid());
        }
        return new ResultBean<>(logService.getAll(log));
    }
}
